<extend name="Center/base"/>
<block name="main_content">
    <div class=" pd10 common_block_border">
        <form model-node="normal_form" class="form-horizontal" action="{:U('store/Center/pay_ok')}" method="post">
            <div>
                <h2 class="common_block_title">收货地址确认</h2>

                <div class="clearfix"></div>
                <div class="pd20">
                    <div class="form-group has-feedback ">
                        <label class="col-xs-2 control-label"><span
                                class="c_empty">*</span>收货人姓名</label>

                        <div class="col-xs-5">
                            <input name="r_name" event-node="input_text" class="form-control"
                                   event-args="min=2&max=20&error=收货人姓名必填" type="text" maxlength="20" style="width: 150px"
                                   value="{$address.r_name}">
                            <span class="help-block">必须填写。</span>
                        </div>
                    </div>

                    <div class="form-group has-feedback ">
                        <label class="col-xs-2 control-label"><span
                                class="c_empty">*</span>邮政编码</label>

                        <div class="col-xs-5">
                            <input name="r_code" event-node="input_text" class="form-control"
                                   event-args="min=1&error=必须填写邮箱地址" type="text" maxlength="20" style="width: 150px"
                                   value="{$address.r_code}">
                            <span class="help-block">收件人所在地的邮编。</span>
                        </div>
                    </div>

                    <div class="form-group has-feedback ">
                        <label class="col-xs-2 control-label"><span
                                class="c_empty">*</span>手机号码</label>

                        <div class="col-xs-5">
                            <input name="r_phone" event-node="input_text" class="form-control"
                                   event-args="min=1&error=必须填写手机号码" class="tright" type="text" maxlength="20"
                                   value="{$address.r_phone}">
                            <span class="help-block">填写收货人的手机号码，用于快递签收。</span>
                        </div>
                    </div>
                    <div class="form-group has-feedback ">
                        <label class="col-xs-2 control-label"><span
                                class="c_empty">*</span>具体收货地址</label>

                        <div class="col-xs-5">
                            <textarea name="r_pos" event-node="input_text" class="form-control"
                                      event-args="min=5&error=必须填写详细收货地址，不可少于5个汉字" class="tright" maxlength="100"
                                      style="width: 250px;height: 50px">{$address.r_pos}</textarea>
                            <span class="help-block">越详细越好，尽可能详细到门牌号。至少填写5个汉字。</span>
                        </div>
                    </div>

                </div>

            </div>


            <h2 class="common_block_title">确认订单信息</h2>


            <div class="clearfix"></div>
            <div class="pd10">
                <ul>
                    <volist name="goods" id="vo">
                        <li class="pd10 f12px clearfix item_line">
                            <div class="col-xs-3"><img style="width: 50px;height: 50px" src="{$vo.good.cover_id|getThumbImageById=50,50}">
                                <a style="font-size: 14px;max-width: 100%" class="text-more"
                                   href="{:U('cat/Index/info',array('info_id'=>$vo['id']))}" target="_blank">{$vo.good.title|getShort=10}</a>
                                <br/>
                            </div>
                            <div class="col-xs-6" style="line-height: 28px;">
                                <input type="hidden" class="comput_count pd5 tcenter f14px" name="good_id[]"
                                       value="{$vo.good.id}">
                                ￥ <span class="comput_cny"
                                        data="{$vo.good.price}">{$vo.good.price|number_format=2}</span>元
                                &nbsp;&nbsp;<b>X</b>
                                <input type="text" readonly style="width: 40px;border: none;background: none"
                                       name="count[]"
                                       class="comput_count pd5 tcenter f14px" data="{$vo['good_id']}"
                                       value="{$_POST['count'][$key]}">
                            </div>
                            <div class="col-xs-3" style="line-height: 28px;">
                                = &nbsp;&nbsp;<span class="comput_row_total f14px"></span>
                            </div>
                            <div class="clearfix"></div>
                        </li>
                    </volist>
                </ul>
            </div>
            <div class="pd10 tright f16px">
                <span class="">订单总价：</span> ￥ <span class="comput_total_cny"></span> &nbsp;&nbsp;&nbsp;&nbsp;
                <br/>
                <br/>
                <input class="c_btn_buy" type="submit" value="确认无误">
            </div>

        </form>
    </div>


</block>
<block name="style">
    <style>
        .item_line:hover {
            background: #ebf6ff;
        }

        .item_line {
            border: dotted 1px #ccc;
            margin-top: -1px;
        }

    </style>
</block>
<block name="script">
    <script src="__JS__/module.js"></script>
    <script src="__JS__/cat_form.js"></script>
    <script>
        var total_cny = 0;
        var time_limit = 15;
        $(function () {
            $('.comput_count').change(comput_event);
            $('.comput_count').each(comput_event);
        });

        getRate = function getRate() {

            time_limit--;
            if (time_limit <= 0) {
                //半分钟到
                time_limit = 15;
                $.getJSON(U('cat/Center/_getRate'), function (msg) {
                    $('#rate').text(msg.data);
                    $('.comput_count').each(comput_event);
                });

            }
            $('#loading').text(time_limit);
        };
        comput_event = function comput() {
            if (isNaN($(this).val())) {
                $(this).val(1);
            } else {
                if ($(this).val() <= 0) {
                    $(this).val(1);
                }
            }
            var cny = parseFloat($(this).parents('.item_line').eq(0).find('.comput_cny').attr('data'));


            var count = $(this).val();
            var good_id = $(this).attr('data');
            $.post(U('cat/Center/_cart_set_item_count'), {good_id: good_id, count: count}, function (msg) {
            }, 'json');

            $(this).parent().parent().find('.comput_row_total').html('￥ <span class="comput_line_cny" data="' + (cny * count) + '">' + fmoney(cny * count, 2) + '</span>元 ');
            comput_all();
        };
        comput_total_cny = function () {
            total_cny += parseFloat($(this).attr('data'));
        };
        comput_all = function () {
            total_cny = 0;
            $('.comput_line_cny').each(comput_total_cny);
            $('.comput_total_cny').text(fmoney(total_cny, 2));
        };


        function fmoney(s, n) {
            n = n > 0 && n <= 20 ? n : 2;
            s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
            var l = s.split(".")[0].split("").reverse(),
                    r = s.split(".")[1];
            t = "";
            for (i = 0; i < l.length; i++) {
                t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
            }
            return t.split("").reverse().join("") + "." + r;
        }
    </script>
</block>

<script src="__THEME__/js/module.form.js"></script>
<include file="__THEME__/public_footer"/>